source ./config.sh
source ./logging.sh

# Usage: hl_and_convert <input file> <output file>
hl_and_convert() {
	highlight --pretty-symbols $1 | sed -n '/<pre/,/<\/pre/p' | sed 's/<pre class="hl">//; s/<\/pre>//' | \
		sed 's/<span class="hl com">/<span class="comment">/g' | \
		sed 's/<span class="hl slc">/<span class="comment">/g' | \
		sed 's/<span class="hl opt">/<span class="operand">/g' | \
		sed 's/<span class="hl kwa">/<span class="keyword">/g' | \
		sed 's/<span class="hl kwb">/<span class="identifier-native">/g' | \
		sed 's/<span class="hl kwd">/<span class="identifier-udf">/g' | \
		sed 's/<span class="hl num">/<span class="value">/g' | \
		sed 's/^/    <span class="newline">/' | \
		sed 's/$/<\/span>/' > $2

	# Because highlight also drops 'highlight.css' and we dont need that, remove it.
	rm highlight.css
}
